package com.uh.microservice.core.dto;

import com.uh.microservice.core.util.JSONParser;

import java.util.HashMap;
import java.util.Map;

/**
 * AKKA异步消息体对象
 * @author liming
 * @date 2017/9/15
 */
public class AkkaMsg {
    final private String fn;
    final private Object body;
    final private Integer id;
    private Long waitTime=0L;

    /**
     *  akka消息体构造函数
     */
    public AkkaMsg(String fn,Object body,Integer id){
        this.fn=fn;
        this.body=body;
        this.id=id;
    }

    /**
     *  akka消息体构造函数，带等待时间
     */
    public AkkaMsg(String fn,Object body,Integer id,Long wait){
        this.fn=fn;
        this.body=body;
        this.id=id;
        this.waitTime=wait;
    }

    public String getFn(){return fn;}
    public Object getBody() { return body; }
    public Integer getId() { return id; }
    public Long getWaitTime() { return waitTime;   }

    /**
     *  akka消息体的JSON数据
     */
    public String toString(){
        Map mp=new HashMap();
        mp.put("fn",fn);
        mp.put("body",body);
        mp.put("id",id);
        return JSONParser.obj2Json(mp);
    }
}
